﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApp3.Models;
using WpfApp3.ViewModels;

namespace WpfApp3
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new MainViewModel();

        }
        private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // 方法通过ListView的SelectedItem属性获取
            var listView = sender as ListView;
            var selectedPerson = listView.SelectedItem as Person;

            if (selectedPerson != null)
            {
                MessageBox.Show($"选中人员: {selectedPerson.Name}");

            }


        }

    }
}
